import {
  http
} from "../../utils/http";
Page({
  data: {
    detail: {}, //医院详情
  },
  async onLoad(e) {
    var id = e.id; //获取到医院id
    // 请求详情接口
    var result = await http({
      url: "/87-59",
      data: {
        id: id
      }
    }).catch(err => {
      console.error(err)
    })
    // console.log(result)
    this.setData({
      detail: result.data.showapi_res_body
    })
  },
  //添加收藏
  addLike() {
    // var arr=[]
    var arr = wx.getStorageSync('like') || [];

    var hosName = this.data.detail.hosName; //医院名称
    //检测医院在数组中是否存在
    var index = arr.findIndex(item => {
      return item == hosName
    })
    // 
    if (index == -1) {
      arr.unshift(hosName)
      wx.setStorageSync('like', arr)
    }

  }

})